<template>
	<el-dialog title="创建文件" v-model="visible" :width="400" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="上传文件" prop="attachId">
				<sc-upload-file :apiObj="apiObj" v-model="fileList" :limit="1" :data="{netDiskId:netDiskId,sourcePath:sourcePath}"
				@success="uploadSuccess">
					<el-button type="primary" icon="el-icon-upload">上传附件</el-button>
				</sc-upload-file>
			</el-form-item>
		</el-form>
	</el-dialog>
</template>
<script>
export default {
	components: {},
	emits: ['success', 'closed'],
	props:{
		netDiskId:String,
		sourcePath:String
	},
	data() {
		return {
			apiObj: this.$API.file.netDisk.createNetDiskFile,
			fileList: [],
			form: {
				folderId:this.folderId,
				sortNo: 0,
        attachId: "",
				fileName: "",
				remark: ''
			},
			rules: {},
			visible: false,
			isSaveing: false,
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this;
		},
		uploadSuccess()
		{
			this.visible = false;
			this.$emit('success',{netDiskId:this.netDiskId,filePath:this.sourcePath});
		},
		getAttachIdByList(fileList) {
			var _arr = [];
			fileList.forEach(item => {
				_arr.push(item.attachId);
			})
			return _arr.join(",")
		},
		//表单注入数据
		setData(data) {
		}
	}
}
</script>

<style>
</style>
